package com.npjscg.medicalpro.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.npjscg.medicalpro.common.Constants;
import com.npjscg.medicalpro.common.Result;

import com.npjscg.medicalpro.controller.dto.TemplateDTO;
import com.npjscg.medicalpro.entity.Check;
import com.npjscg.medicalpro.entity.User;
import com.npjscg.medicalpro.service.ICheckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author raote
 * @since 2022-06-30
 */
@Api(tags = "报表状态管理模块")
@RestController
@RequestMapping("/check")
public class CheckController {

    @Resource
    private ICheckService checkService;

    //提供未通过或通过的report 根据模板id来查 提供status来提供状态 0：未审核 1：退回 2：通过
    @ApiOperation(value = "提供未通过或通过的report 根据模板id来查")
    @GetMapping(value = {"/getCheckInfo/{pagenum}/{pagesize}/{tid}/{status}/{temname}","/getCheckInfo/{pagenum}/{pagesize}/{tid}/{status}"})
    public Result getCheckInfo(@PathVariable int pagenum, @PathVariable int pagesize, @PathVariable int tid, @PathVariable int status,@PathVariable(required = false) String temname){
        Page<TemplateDTO> page = new Page<>(pagenum,pagesize);
        return Result.success(checkService.getCheckInfo(page,tid,status,temname));
    }

    //提供rid来改变status状态
    @ApiOperation(value = "提供rid来改变status状态")
    @GetMapping("/changeStatus/{rid}/{currentStatus}/{adminid}")
    public Result changeStatus(@PathVariable Integer rid, @PathVariable int currentStatus, @PathVariable int adminid){
        if (rid == null)
            return Result.error(Constants.CODE_600, "id为空出错！");
        else{
            checkService.changeStatus(rid, currentStatus,adminid);
            return Result.success();
        }

    }

    @ApiOperation(value = "添加退回理由")
    @GetMapping("/changeMsg/{rid}/{msg}")
    public Result changeMsg(@PathVariable Integer rid, @PathVariable String msg){
        checkService.changeMsg(rid, msg);
        return Result.success();
    }




}
